
import {Director} from "../Director.js";
import {Sprite} from "../base/Sprite.js";
const screenWidth    = window.innerWidth
const screenHeight   = window.innerHeight

export class Foods extends Sprite {
    constructor(image){      
        super(image, 0, 0, image.width, image.height,
            0, 0, 40, 40);
        this.x=Math.random()*screenWidth;
        this.y=-Math.random()*150
        this.index=0
        this.dropSpeed = Director.getInstance().moveSpeed
    }

    draw(){
        this.y = this.y + this.dropSpeed;

        // if (this.y > (screenHeight)) {
        //     this.y = -Math.random()*100;
        //     this.x=Math.random()*screenWidth;
        // }
        super.draw(this.image,
            this.srcX,
            this.srcY,
            this.srcW,
            this.srcH,
            this.x,
            this.y,
            this.width,
            this.height)
    }
}